package cn.sunjinxin.trade.domain.statemachine;

import cn.sunjinxin.trade.domain.even.OrderEvent;
import cn.sunjinxin.trade.domain.even.TradeEvent;
import cn.sunjinxin.trade.domain.status.FundStatus;
import cn.sunjinxin.trade.domain.status.OrderStatus;

/**
 * @author issavior
 */
public class FundStateMachine extends BaseStateMachine<FundStatus, TradeEvent> {

    public static final FundStateMachine INSTANCE = new FundStateMachine();

    {
//        putTransition(OrderStatus.CREATE, TradeOrderEvent.CONFIRM, OrderStatus.CONFIRM);
//        putTransition(OrderStatus.CONFIRM, TradeOrderEvent.PAY, OrderStatus.PAID);
//        //库存预扣减成功，但是未真正扣减成功，也能支付/取消，不能因为延迟导致用户无法支付/取消。
//        putTransition(OrderStatus.CREATE, TradeOrderEvent.PAY, OrderStatus.PAID);
//        putTransition(OrderStatus.CREATE, TradeOrderEvent.CANCEL, OrderStatus.CLOSED);
//        putTransition(OrderStatus.CREATE, TradeOrderEvent.TIME_OUT, OrderStatus.CLOSED);
//
//        //已支付后，再确认，状态不变
//        putTransition(OrderStatus.PAID, TradeOrderEvent.CONFIRM, OrderStatus.PAID);
//
//        putTransition(OrderStatus.CONFIRM, TradeOrderEvent.CANCEL, OrderStatus.CLOSED);
//        putTransition(OrderStatus.CONFIRM, TradeOrderEvent.TIME_OUT, OrderStatus.CLOSED);
//
//        putTransition(OrderStatus.PAID, TradeOrderEvent.FINISH, OrderStatus.FINISH);
    }

}
